package com.larry.mapreduce.partitioner2;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @ProjectName MapReduceDemo
 * @Author larry
 * @Date 18:15 2021/11/7
 * @Description 自定义分区
 *
 * 自定义分区
 **/
public class ProvincePartitioner extends Partitioner<Text,FlowBean> {

    @Override
    public int getPartition(Text text, FlowBean flowBean, int i) {

        String phone = text.toString();
        String proPhone = phone.substring(0, 3);

        int part;
        if ("136".equals(proPhone)){
            part = 0;
        }else if ("137".equals(proPhone)){
            part = 1;
        }else if ("138".equals(proPhone)){
            part = 2;
        }else if ("139".equals(proPhone)){
            part = 3;
        }else {
            part = 4;
        }


        return part;
    }
}
